package com.ai.aicodemather.model.enums;

import cn.hutool.core.util.ObjUtil;
import lombok.Getter;

import static com.ai.aicodemather.constant.UserConstant.ADMIN_ROLE;
import static com.ai.aicodemather.constant.UserConstant.DEFAULT_ROLE;

@Getter
public enum UerRoleTypeEnum {

    ADMIN("管理员", ADMIN_ROLE),
    USER("普通用户", DEFAULT_ROLE);

    private String text;
    private String value;

    UerRoleTypeEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    public static UerRoleTypeEnum getEnumByValue(String value) {
        if (ObjUtil.isNull(value)) {
            return null;
        }
        for (UerRoleTypeEnum type : UerRoleTypeEnum.values()) {
            if (type.getValue().equals(value)) {
                return type;
            }
        }
        return null;
    }
}
